function g = grad ( wk,tk,rk,b)
load Am;

T=A(:,4);
R=A(:,5);
BT_B=A(:,1:3)'*A(:,1:3);
ksai=T*tk+R*rk-b;
g=[BT_B(1,:)*wk+A(:,1)'*ksai;BT_B(2,:)*wk+A(:,2)'*ksai;BT_B(3,:)*wk+A(:,3)'*ksai];
end
    